import { NetWorkService } from "../../apiNetworkServices"

/**
 * Network request used to fetch ethera clients
 * @returns the response containing clients
 */

//TODO add pagination
const getEtheraClients = () => {
  return new Promise((resolve, reject) => {
    NetWorkService.Get({
      url: `/api/clients?offset=0&limit=1000`,
    })
      .then((res) => {
        resolve(res)
      })
      .catch((error) => reject(error))
  })
}

/**
 * Network request used to fetch ethera services
 * @returns the response containing clients services
 */

//TODO add pagination
const getClientServices = ({ clientId }: { clientId: string }) => {
  return new Promise((resolve, reject) => {
    NetWorkService.Get({
      url: `/api/client-service?clients=["${clientId}"]&offset=0&limit=200`,
    })
      .then((res) => {
        resolve(res)
      })
      .catch((error) => reject(error))
  })
}

export { getEtheraClients, getClientServices }
